/*
 * @Author: Ma Yuchen
 * @Date: 2023-07-15 10:15:45
 * @LastEditors: Ma YuChen
 * @LastEditTime: 2023-08-03 10:14:20
 * @Description: file content
 * @FilePath: \video-repeater-ctl-mcu\main.c
 */
#include <stdio.h>

#include "systick.h"
#include "bsp_i2c.h"
#include "ctl_lt86101.h"
#include "lt_global.h"
#include "ctl_lt86101_gpio.h"
#include "bsp_usart.h"

LT_GLOBAL lt_chip[2];

int main(void)
{
	systick_config();
	init_usart();

	delay_1ms(2000);
	gpio_lt86101_pin();

	printf("MCU 86101 ctl Power on\r\n");
	MASTER_I2C_Init();

	// delay_1ms(400);
	lt_chip[0].chipNo = 1;
	lt_chip[0].i2c_periph = I2C0;
	lt_chip[1].chipNo = 2;
	lt_chip[1].i2c_periph = I2C1;

	while (1)
	{

		if (!lt_chip[0].g_Flag_Init_Finished)
		{
			lt86101_init(&lt_chip[0]);
		}
		else
		{
			vStart_work(&lt_chip[0]);
			CLK_det(&lt_chip[0]);
			vdClk_Stable_Config(&lt_chip[0]);
#if 0
						vdPrintError(&lt_chip[0]);//used to print the error conter,it can show the input signal quality
#endif
		}

		if (!lt_chip[1].g_Flag_Init_Finished)
		{
			lt86101_init(&lt_chip[1]);
		}
		else
		{
			vStart_work(&lt_chip[1]);
			CLK_det(&lt_chip[1]);
			vdClk_Stable_Config(&lt_chip[1]);

#if 0
						vdPrintError(&lt_chip[1]);//used to print the error conter,it can show the input signal quality
#endif
		}
	}
}
